package web.action;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

import util.RandomCodeUtil;

/**
 * 验证码控制器
 * @author gongkai
 *
 */
public class RandomCodeAction {
	private ByteArrayInputStream input;
	private Integer width;
	private Integer height;
	private Boolean isChinaCode;
	

	public InputStream getInput() {
		return input;
	}

	public void setInput(ByteArrayInputStream input) {
		this.input = input;
	}

	public Boolean getIsChinaCode() {
		return isChinaCode;
	}

	public void setIsChinaCode(Boolean isChinaCode) {
		this.isChinaCode = isChinaCode;
	}

	public Integer getWidth() {
		return width;
	}

	public void setWidth(Integer width) {
		this.width = width;
	}

	public Integer getHeight() {
		return height;
	}

	public void setHeight(Integer height) {
		this.height = height;
	}

	public String execute() throws Exception {
		RandomCodeUtil.setHeight(height);
		RandomCodeUtil.setWidth(width);
		RandomCodeUtil.setIsChinaCode(isChinaCode);
		this.setInput(RandomCodeUtil.createImg());
		
		//ActionContext.getContext().getSession().put("identify", RandomCodeUtil.getCode());
		return "success";
	}
}
